package com.ajk.server.service.impl;
import java.util.List;

import org.apache.commons.collections4.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.ajk.server.dao.FriendTreatmentPicMapper;
import com.ajk.server.model.FriendTreatmentPic;
import com.ajk.server.model.query.FriendTreatmentPicQuery;
import com.ajk.server.service.FriendTreatmentPicService;

/**
 * 亲友就诊图片  <br>
 * t_friend_treatment_pic <br>
 * v1.0 2016-05-01
 */
 @Service
 public class FriendTreatmentPicServiceImpl implements FriendTreatmentPicService {
	
	private static final Logger logger = LoggerFactory.getLogger(FriendTreatmentPicServiceImpl.class);
	
	@Autowired
	private FriendTreatmentPicMapper friendTreatmentPicMapper;
	
	/**
 	*根据ID删除 亲友就诊图片
 	*/
 	@Override
 	public Integer deleteFriendTreatmentPicById(Integer id){
 		return friendTreatmentPicMapper.deleteById(id);
 	}
 	
 	/**
 	*新增 亲友就诊图片
 	*/
 	@Override
 	@Transactional
 	public Integer batchInsertFriendTreatmentPic(List<? extends FriendTreatmentPic> friendTreatmentPics){
		Integer count = friendTreatmentPicMapper.batchInsert(friendTreatmentPics);
		return count;
 	}
 	/**
 	*新增 亲友就诊图片
 	*/
 	@Override
 	@Transactional
 	public Integer insertFriendTreatmentPic(FriendTreatmentPic domain){
		Integer id = friendTreatmentPicMapper.insert(domain);
		return id;
 	}

 	/**
 	*更新 亲友就诊图片
 	*/
 	@Override
 	@Transactional
 	public Integer updateFriendTreatmentPic(FriendTreatmentPic domain){
		Integer count = friendTreatmentPicMapper.update(domain);
		return count;
 	}
 	
 	/**
 	*根据ID查询 亲友就诊图片
 	*/
 	public FriendTreatmentPic findFriendTreatmentPicById(Integer id){
 		FriendTreatmentPic result = friendTreatmentPicMapper.findById(id);
 		if(result!=null){
 			result.dealWith();
 		}
 		return result;
 	}

	/**
 	*通过query 查询 亲友就诊图片
 	*/
	public List<FriendTreatmentPic> findFriendTreatmentPicByQuery(FriendTreatmentPicQuery query){
		query.dealWith();
		List<FriendTreatmentPic> result = friendTreatmentPicMapper.findByQuery(query);
		if(CollectionUtils.isNotEmpty(result)) {
			for (FriendTreatmentPic friendTreatmentPic : result) {
				friendTreatmentPic.dealWith();
			}
		}
		return result;
	}	
	
	/**
 	*通过query count总条数
 	*/
 	public Integer countFriendTreatmentPicByQuery(FriendTreatmentPicQuery query){
 		query.dealWith();
 		Integer result = friendTreatmentPicMapper.countByQuery(query);
 		return result;
 	}
 	
 	/**
 	* 通过ids查询
 	*/
 	public List<FriendTreatmentPic> findFriendTreatmentPicByIds(List<Integer> ids){
 		List<FriendTreatmentPic> result = friendTreatmentPicMapper.findByIds(ids);
		if(CollectionUtils.isNotEmpty(result)) {
			for (FriendTreatmentPic friendTreatmentPic : result) {
				friendTreatmentPic.dealWith();
			}
		}
		return result;
 	}
 	
}	